﻿using System;
using Cysharp.Threading.Tasks;
using UnityEngine;

namespace KuiHuaBaoDian.Services.Animation {

    /// <summary>
    /// 动画方案
    /// </summary>
    public interface IAnimationScheme {

        /// <summary>
        /// 控制器资产名称, 当值为<code>null</code>时不覆盖控制器
        /// </summary>
        string ControllerAssetName { get; }

        /// <summary>
        /// 加载
        /// </summary>
        /// <param name="controller">应用此方案的控制器</param>
        /// <returns>异步任务</returns>
        UniTask Load(AnimatorOverrideController controller);

        /// <summary>
        /// 覆盖
        /// </summary>
        /// <param name="clipName">动画剪辑名称</param>
        /// <param name="assetKey">资产键</param>
        /// <returns>异步任务</returns>
        UniTask Override(AnimationClipName clipName, string assetKey);

        /// <summary>
        /// 尝试取得此方案模拟的无限状态机扩展
        /// </summary>
        /// <param name="state">以此有限状态为基础</param>
        /// <param name="result">如果成功则可以取得控制这个扩展的相关信息</param>
        /// <returns>成功或失败</returns>
        bool TryMoveNextExtension(AnimationState state, out (AnimationState, AnimationTrigger, AnimationClipName) result);

        /// <summary>
        /// 尝试取得此方案模拟的无限状态机扩展
        /// </summary>
        /// <param name="trigger">以此触发为基础</param>
        /// <param name="result">如果成功则可以取得控制这个扩展的相关信息</param>
        /// <returns>成功或失败</returns>
        bool TryMoveNextExtension(AnimationTrigger trigger, out (AnimationState, AnimationTrigger, AnimationClipName) result);
    }
}
